{literal}

<script>

function getAddForm(){
		
	$.ajax({
		type: "GET",
		url: "/languages/add",
		data: {
			
		},
		success: function(data){
			showPopup(data, 'Add new language', false);
		},
		error: function(xhr, statusText, errorThrown){
			showPopup(xhr.responseText, statusText, false);
		}    
	
	});
}

function getEditForm(languagesId){
		
	$.ajax({
		type: "GET",
		url: "/languages/edit",
		data: {
			languagesId: languagesId
		},
		success: function(data){
			showPopup(data, 'Edit details', false);
		},
		error: function(xhr, statusText, errorThrown){
			showPopup(xhr.responseText, statusText, false);
		}    
	
	});
}

function getTranslations(languagesId){
		
	$.ajax({
		type: "GET",
		url: "/locale/translations/"+languagesId,
		data: {
			languagesId: languagesId
		},
		success: function(data){
			showPopup(data, 'Edit details', false);
		},
		error: function(xhr, statusText, errorThrown){
			showPopup(xhr.responseText, statusText, false);
		}    
	
	});
}

function generateTranslations(languagesId){
	$.ajax({
		type: "GET",
		url: "/locale/generate-translations",
		data: {
			languagesId: languagesId
		},
		success: function(data){
			alert(data);
			//$('#translationsBox').html(data);
			//showPopup(data, 'Edit details', false);
		},
		error: function(xhr, statusText, errorThrown){
			showPopup(xhr.responseText, statusText, false);
		}    
	
	});
}
</script>

{/literal}

{strip}
<!-- content -->
<div id="content">
    <div id="content_left">
    	<div>
			<h2>LANGUAGES</h2>
		</div>

		<div>
			<a class="button_" href="#" onclick="getAddForm();">{$commonLocale->t('ADD NEW')}</a>
		</div>

	
		<table cellpadding="2" cellspacing="2" class="activeTable">
			<tr>
				<td>ID</td>
				<td>LANGUAGE</td>
				<td>SHORT_CUT</td>
				<td> </td>
			</tr>
		{foreach from=$languages item=l name=forU}
			<tr>
				<td>{$l->getId()}</td>
				<td>{$l->getLanguage()}</td>
				<td>{$l->getShortcut()}</td>
				<td><a href="#" onclick="getEditForm({$l->getId()});">EDIT</a></td>
				<td><a href="#" onclick="getTranslations({$l->getId()});">TRANSLATE</a></td>
				<td><a href="#" onclick="generateTranslations({$l->getId()});">Generate localization files</a></td>
			</tr>
		{/foreach}
		</table>
	</div>
	<div id="content_right">
		{include file='admin/menu.tpl'}
	</div>
</div>
<!-- end content  -->
{/strip}